package com.slz3.business.module.goodsManagement.baseGoods.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.goodsManagement.baseGoods.domain.BaseGoods;
import com.slz3.business.module.goodsManagement.baseGoods.domain.BaseGoodsCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class BaseGoodsResController{

    @Resource
    private BaseGoodsResAtomic baseGoodsResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, BaseGoods baseGoods) {
        if (BaseGoodsResUnsafeValid.add(req, baseGoods)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.add_$BaseGoodsUpdateLock(req, baseGoods);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, BaseGoodsCondition baseGoodsCondition) {
        if (BaseGoodsResUnsafeValid.delete(req, baseGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.delete_$BaseGoodsUpdateLock(req, baseGoodsCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, BaseGoods baseGoods) {
        if (BaseGoodsResUnsafeValid.modify(req, baseGoods)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.modify_$BaseGoodsUpdateLock(req, baseGoods);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (BaseGoodsResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return BaseGoodsResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return baseGoodsResAtomic.info_$BaseGoodsUpdateLock(req);
        if (BaseGoodsResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.info_$BaseGoodsUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (BaseGoodsResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return BaseGoodsResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, BaseGoodsCondition baseGoodsCondition) {
        //
        if (BaseGoodsResUnsafeValid.auditSubmit(req, baseGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.auditSubmit_$BaseGoodsUpdateLock(req, baseGoodsCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, BaseGoodsCondition baseGoodsCondition) {
        if (BaseGoodsResUnsafeValid.audit(req, baseGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.audit_$BaseGoodsUpdateLock(req, baseGoodsCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, BaseGoodsCondition baseGoodsCondition) {
        if (BaseGoodsResUnsafeValid.auditReject(req, baseGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.auditReject_$BaseGoodsUpdateLock(req, baseGoodsCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, BaseGoodsCondition baseGoodsCondition) {
        if (BaseGoodsResUnsafeValid.usingEnable(req, baseGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.usingEnable_$BaseGoodsUpdateLock(req, baseGoodsCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, BaseGoodsCondition baseGoodsCondition) {
        if (BaseGoodsResUnsafeValid.usingDisable(req, baseGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return baseGoodsResAtomic.usingDisable_$BaseGoodsUpdateLock(req, baseGoodsCondition);
        }
    }

}
